<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		.box1{
			width: 200px;
			height: 200px;
			background: red url() 0 0 no-repeat;
			font-size: 30px;
			text-align: center;
			color: #fff;
			line-height: 200px;
			float: left;
		}
		.box2{
			width: 200px;
			height: 200px;
			background: blue url() 0 0 no-repeat;
			font-size: 30px;
			text-align: center;
			color: #fff;
			line-height: 200px;
			float: left;
		}

	</style>
	<script type="text/javascript">
		window.onload = function  () {

			box1 = document.getElementById('box1');
			box2 = document.getElementById('box2');


			box1.onclick = function  () {
				text = box2.innerHTML;
				box1.innerHTML = text;
				box2.innerHTML = '';
			}

			box2.onclick = function  () {
				text = box1.innerHTML;
				box2.innerHTML = text;
				box1.innerHTML='';
			}

			input = document.getElementById('input');

			input.onblur =  function  (argument) {
				data = input.value;
				if(data.length==0){
					alert("这个是必填项");
					input.style.border="1px solid red";
				}else if(data.length<20){
					alert("长度不能少于20");
					input.style.border="1px solid red";
				}
			}

			input.onfocus = function  () {
				input.style.border="1px solid #A9A9A9";
			}



		
			
		}
	</script>
</head>
<body>
	<input type="text" id="input">
	<div id="box1" class="box1">学并思</div>
	<div id="box2" class="box2"></div>
</body>
</html>